package com.hxy.util;

import com.hxy.entity.Buser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Component
public class  AuthUserUtils {

    public static Authentication getAuthentication(){
        return SecurityContextHolder.getContext().getAuthentication();
    }
    public static Buser getAuthUser(){

        Authentication authentication=getAuthentication();
        return (Buser) authentication.getPrincipal();
    }
    public static String getName(){


        Authentication authentication=getAuthentication();
        return authentication.getName();
    }
    /*public static Authentication AUTHENTICATION;
    public static Buser Buser;
    public void getAuthentication(){
        this.AUTHENTICATION=SecurityContextHolder.getContext().getAuthentication();
    }
    public void getAuthUser(){
        getAuthentication();
        this.Buser =(Buser) this.AUTHENTICATION.getPrincipal();
    }*/
}
